
package kcluserdemo;

import com.kweative.cluster.Cluster;
import java.io.IOException;
import java.io.Serializable;
import java.util.Date;

/**
 *
 * @author henrik
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException, InterruptedException {
        Cluster.instance().connect();
        
        while(true) {
            Integer i = (Integer) Cluster.get("Counter",new Integer(1));
            Date d = new Date();
            System.out.println(d.toString() + " " + Cluster.node() + ": " + i);
            
            if (Cluster.isMaster()) {
                i++;
                Cluster.store("Counter", i);
            }
            Thread.sleep(500);
        }
    }

}
